﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Skyhook.Core.Configuration
{
    class DataCollection<T> : IDataCollection<T> where T : Data, new()
    {
        Dictionary<string, T> Dictionary = new Dictionary<string, T>();

        public DataCollection()
        {
        }

        public void Add(Data data)
        {
            Dictionary.Add(data.Type, data as T);
        }

        public void Remove(Data data)
        {
            Dictionary.Remove(data.Type);
        }

        public IEnumerable<T> Values
        {
            get
            {
                return Dictionary.Values;
            }
        }

        public T this[string type]
        {
            get
            {
                T result = null;
                if (Dictionary.TryGetValue(type, out result))
                {
                    return result;
                }

                return null;
            }
        }

        public void Clear()
        {
            Dictionary.Clear();
        }
    }
}
